<template>
  <div>
    <image-title :title="title"></image-title>
    <div class="early-warning-list">
      <vue-seamless-scroll
        v-if="warningList.length > 0"
        style="width: 100%; height: 100%"
        :data="warningList"
        :class-option="classOption"
      >
        <div
          v-for="(item, index) in warningList"
          :key="index"
          class="early-warning"
        >
          {{ item }}
        </div>
      </vue-seamless-scroll>
    </div>
  </div>
</template>

<script>
import imageTitle from "./image-title";
import vueSeamlessScroll from "vue-seamless-scroll";

export default {
  name: "early-warning",
  props: {
    title: {
      type: String,
      default: "",
    },
    warningList: {
      type: Array,
      default: () => [],
    },
    keys: {
      type: String,
      default: "",
    },
  },
  computed: {
    classOption() {
      return {
        step: 0.2, // 数值越大速度滚动越快
        limitMoveNum: this.warningList.length, // 开始无缝滚动的数据量 this.dataList.length
        hoverStop: true, // 是否开启鼠标悬停stop
        direction: 1, // 0向下 1向上 2向左 3向右
        openWatch: true, // 开启数据实时监控刷新dom
        singleHeight: 0, // 单步运动停止的高度(默认值0是无缝不停止的滚动) direction => 0/1
        singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
        waitTime: 2000,
      };
    },
  },
  components: {
    imageTitle,
    vueSeamlessScroll,
  },
};
</script>

<style scoped>
.early-warning-list {
  width: 100%;
  height: 33vh;
  overflow-y: scroll;
  margin-top: 1.14rem;
  scrollbar-width: none;
}
.early-warning-list::-webkit-scrollbar {
  display: none; /* 对于Chrome, Safari和Opera */
}

.early-warning {
  width: 96%;
  border: 0.0714rem solid #2e6aa6;
  padding: 0.714rem 0.643rem;
  font-weight: 400;
  line-height: 1.6rem;
  color: #ffffff;
  font-size: 0.8rem;
  margin-top: 1rem;
}
</style>
